

function addSensorbitCod(Blockly) {




    //直流电机模块
 Blockly.Python.microbit_motor = function(block) {
    var dropdown_motorINA = this.getFieldValue('INA');
    var dropdown_motorINB = this.getFieldValue('INB');
    var dropdown_direction = this.getFieldValue('direction');
    var dropdown_motorSpeed = Blockly.Python.valueToCode(this, 'motorSpeed', Blockly.Python.ORDER_ATOMIC);
    Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
    Blockly.Python.definitions_['import_Motor'] = 'from actuator import dc_motor';
    var code = "";
    if(dropdown_direction === "forward"){
      code = "dc_motor.run("+ dropdown_motorINA +", "+ dropdown_motorINB +", int("+ dropdown_motorSpeed +"))\n";
    }else if(dropdown_direction === "reverse"){
      code = "dc_motor.run("+ dropdown_motorINA +", "+ dropdown_motorINB +", int(-"+ dropdown_motorSpeed +"))\n";
    }
    return code;
  }

    return Blockly;
}

module.exports = addSensorbitCod;

